package com.ebraga.trackerclub.android.thread.service;

import com.ebraga.trackerclub.android.handler.api.SyncDataHandler;
import com.ebraga.trackerclub.android.handler.service.SyncDataServiceHandler;
import com.ebraga.trackerclub.android.util.DLog;
import com.ebraga.trackerclub.android.util.api.AndroidContext;

public class SyncService implements Runnable {

	private static SyncService instance;
	private final AndroidContext context;
	
	private SyncService(AndroidContext context) {
		this.context = context;
	}
	
	public static SyncService getInstance(AndroidContext context) {
		if(instance == null)
			instance = new SyncService(context);
		
		return instance;
	}
	
	@Override
	public void run() {
		try {
			SyncDataHandler syncDataHandler = new SyncDataServiceHandler(context);
			syncDataHandler.doSync();
			
		} catch (Throwable e) {
			DLog.e(e);
		}
	}
}
